﻿using CoreProject.IRepository;
using CoreProject.Model;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace CoreProject.Repository
{
    public class HJQ_orderReporitory : BaseRepository<HjqOrder>, IHJQ_orderReporitory
    {
        private readonly EFDbContext _con;

        public HJQ_orderReporitory(EFDbContext con) : base(con)
        {
            _con = con;
        }

        public async Task<(List<HjqOrder> list, int count)> getpageOrder<type>(int page, int limit, bool IAs, Expression<Func<HjqOrder, type>> orderlabd, Expression<Func<HjqOrder, bool>> wherelabdm)
        {
            var list = _con.Set<HjqOrder>().Include(a => a.User).Include(a => a.HjqOrderDetails).ThenInclude(a =>a.Product).Where(wherelabdm).AsQueryable();
            int count = list.Count();
            var data = await list.OrderBy(orderlabd).Skip((page - 1) * limit).Take(limit).ToListAsync();
            return (data, count);
        }
    }
}
